﻿using Shumei.EFCore.Model;
using Shumei.EFCore.SimpleService;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace source.Controllers
{
    public class HomeController : Controller
    {
        CourseService courseService;
        NewsService newService;
        public HomeController() { 
            courseService = new CourseService();
            newService = new NewsService();
        }
        public ActionResult Index()
        {
            List<Course> courses = courseService.FindAtLast(4);
            ViewData["courses"] = courses;
            List<Course> lastCourse = courseService.FindAtLast(8);
            ViewData["lastCourse"] = lastCourse;

            List<Course> gameCourse = courseService.Find_Type(1).Take(8).ToList();
            ViewData["gameCourse"] = gameCourse;

            List<Course> cartoonCourse = courseService.Find_Type(2).Take(8).ToList();
            ViewData["cartoonCourse"] = cartoonCourse;

            int totalPage = 0;
            List<New> news = newService.GetNewsList(1, out totalPage);
            ViewData["news"] = news;
            
            return View();
        }
    }
}